package com.usian.controller;

import com.usian.pojo.TbItem;
import com.usian.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class CartServiceController {

    @Autowired
    private CartService cartService;

    @RequestMapping("getCartFromRedis")
    public Map<String, TbItem> getCartFromRedis(@RequestParam String userId){
        return cartService.getCartFromRedis(userId);
    }

    @RequestMapping("addCartToRedis")
    public Boolean addCartToRedis(@RequestParam String userId,@RequestBody Map<String, TbItem> cart){
        return cartService.addCartToRedis(userId,cart);
    }

}
